const defaultState = {
    token: null,
    menus: []
}

export default (state = defaultState, action: any) => {

    const { type, data } = action;
    console.log(type, 'type');
    if (type === 'TOKEN') {

        const newtype = JSON.parse(JSON.stringify(state))
        console.log(newtype, 'newtype1');
        newtype.token = data
        console.log(data, 'data1');
        
        return newtype
    }
    if (type === 'MENU') {
        const newtype = JSON.parse(JSON.stringify(state))
        console.log(newtype, 'newtype2');

        newtype.menus = data
                console.log(data, 'data2');
        return newtype
    }
    return state;
}